package me.zhengjie.modules.rest.enterprise;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.modules.domain.enterprise.EnterpriseLegalAction;
import me.zhengjie.modules.service.EnterpriseLegalService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api("诉讼信息api")
@RestController
@RequiredArgsConstructor
@RequestMapping("/enterLeg")
public class EnterpriseLegalController {

    private final EnterpriseLegalService enterpriseLegalService;

    @ApiOperation("根据企业名称查询诉讼信息")
    @AnonymousAccess
    @GetMapping("/queryEnterpriseLegalByName")
    public Map<String,Object> queryEnterpriseLegalByName(String name, @RequestParam Integer pageNo,@RequestParam Integer pageSize){
        Map<String,Object> map=new HashMap<>();
        map.put("name",name);
        map.put("pageNo",(pageNo-1)*pageSize);
        map.put("pageSize",pageSize);
        List<EnterpriseLegalAction> list=enterpriseLegalService.queryEnterpriseLegalByName(map);
        int total=enterpriseLegalService.queryEnterpriseLegalByNameToTotal(map);
        map=new HashMap<>();
        map.put("list",list);
        map.put("total",total);
        return map;
    }

}
